<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>四舍五入，输入一个小数如果小数点后大于 3 位那么四舍五入保留两位，小于 3 位不变</title>
</head>

<body>
  <script>
    var i = 1.25
    var len = i.toFixed(3).length;
    if (len >= 3) {
      console.log(i.toFixed(2));
    } else {
      console.log(i);
    }
  </script>
</body>

</html>